import { reactive } from 'vue'

export interface IDept {
    type: string,
    id: string | number,
    name: string,
    director: string,
    director_tel: string,
    remarks: string,
    ord: string | number,
    pid: number
}

export default function useDeptModel() {
    //初始化数据
    const iDeptModel = (): IDept => {
        return {
            type: '',
            id: 0,
            name: '',
            director: '',
            director_tel: '',
            remarks: '',
            ord: 0,
            pid: 0
        }
    }

    // 部门验证规则
    const deptRules = reactive({
        name: [{
            required: true,
            message: '请填写部门名称！',
            trigger: 'blur',
        }, {
            max: 32,
            message: '最大长度32位',
            trigger: 'blur'
        }],
        director: [{
            max: 32,
            message: '最大长度32位',
            trigger: 'blur'
        }],
        director_tel: [{
            max: 15,
            message: '最大长度15位',
            trigger: 'blur'
        }],
        remarks: [{
            max: 255,
            message: '最大长度255位',
            trigger: 'blur'
        }],
        ord: [{
            required: true,
            pattern: /^(0|[1-9][0-9]*)$/,
            message: '请填写数字！',
            trigger: 'blur',
        }]
    })

    return { iDeptModel, deptRules }
}

